package com.cloud.class04.resp;

import lombok.Data;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2024/4/10 14:35
 */
@Data
public class ResultData<YXY> {
    private String code;
    private String message;
    private YXY data;
    private long timestamp;

    public ResultData() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <YXY> ResultData<YXY> success(YXY t) {
        ResultData resultData = new ResultData<>();
        resultData.setCode(ReturnCodeEnum.RC200.getCode());
        resultData.setMessage(ReturnCodeEnum.RC200.getMessage());
        resultData.setData(t);
        return resultData;
    }

    public static <YXY> ResultData<YXY> fail(String code, String message) {
        ResultData resultData = new ResultData<>();
        resultData.setCode(code);
        resultData.setMessage(message);
        return resultData;
    }
}
